package cn.hdu.liang.ch4;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class OReillyByName {
    public static void main(String[] args) {
        getallbyname();
    }

    public static void getallbyname(){
        try {
            InetAddress[] addresses = InetAddress.getAllByName("www.baidu.com");
            for(InetAddress address : addresses) {
                System.out.println(address);
            }
        } catch(UnknownHostException e) {
            System.out.println("无法找到 www.baidu.com");
        }
    }

    public static void getbyname() {
        try {
            InetAddress address = InetAddress.getByName("www.baidu.com");
            System.out.println(address);
        } catch(UnknownHostException e) {
            System.out.println("无法找到 www.baidu.com");
        }
    }
}
